<template>
  <div class="item-menu">
    <el-scrollbar class="scroll-container">
      <ol>
        <li v-for="(item,index) in itemMenuData" :key="`itemMenu_${index}`" :class="{active:itemIndex === index}" @click="handleItem(index,item)">
          <div class="item">
            <div class="content">
              <h6>{{ item.itemName }}</h6>
              <p>{{ item.itemTime }}</p>
            </div>
            <!--          <div class="select-active">-->
            <!--            <img src="~@/assets/patient-details/select_active_1.png" width="16" alt="">-->
            <!--          </div>-->
          </div>
        </li>
      </ol>
    </el-scrollbar>
  </div>
<!--  <div v-else>-->
<!--    <el-empty description="暂无数据" />-->
<!--  </div>-->
</template>

<script>
export default {
  name: 'ItemMenu',
  props: {
    tabType: {
      type: String,
      default: ''
    },
    viewsData: {
      type: String,
      default: ''
    },
    itemMenuData: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      itemIndex: 0
    }
  },
  watch: {
    itemMenuData: {
      handler() {
        this.itemIndex = 0
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    handleItem(index, row) {
      this.itemIndex = index
      this.$emit('handleItemMenu', { row, tabType: this.tabType, viewsData: this.viewsData })
    }
  }
}
</script>
<style lang="scss" >
.item-menu{
  .scroll-container {
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    height: calc(100vh - 184px - 50px);

    .el-scrollbar__wrap {
      overflow-x: hidden;
    }
  }
}

</style>
<style lang="scss" scoped>
.item-menu{
  flex-shrink: 0;
  width:210px;
  background: #F6F6F6;
  li{
    padding:5px 15px;
    cursor: pointer;
    .item{
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      height: 50px;
      border-bottom: 1px solid #DEDEDE;
      .content{
        width: 140px;
        padding-top: 6px;
      }
      .select-active{
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        width: 30px;
        display: none;
      }
      h6{
        height:14px;
        margin-bottom: 8px;
        font-size: 14px;
        color: #333;
        overflow: hidden;  //超出隐藏
        white-space: nowrap; //不折行
        text-overflow: ellipsis; //溢出显示省略号
      }
      p{
        font-size: 12px;
        color: #A2A2A2;
      }

    }
    &:hover h6, &:hover p,
    &.active h6, &.active p{
      color: #fff;
    }
    &.active .select-active img{
      display: none;
    }
    &:hover, &.active{
      background: #29CBDA;
    }
    &:hover .item, &.active .item{
      border-bottom: 1px solid transparent;
    }
  }

}
</style>
